<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - 码上成公</title>
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="/css/bootstrap.css">
    <link rel="stylesheet" href="/vendors/bootstrap-icons/bootstrap-icons.css">
    <link rel="stylesheet" href="/css/app.css">
    <link rel="stylesheet" href="/css/pages/auth.css">
</head>

<body>
<div id="auth">

    <div class="row h-100">
        <div class="col-lg-5 col-12">
            <div id="auth-left">
                <h1 class="auth-title">Welcome</h1>

                <div class="form-group position-relative has-icon-left mb-4">
                    <input type="text" class="form-control form-control-xl" placeholder="邮箱" id="email">
                    <div class="form-control-icon">
                        <i class="bi bi-person"></i>
                    </div>
                </div>
                <div class="form-group position-relative has-icon-left mb-4">
                    <input type="password" class="form-control form-control-xl" placeholder="密码" id="password">
                    <div class="form-control-icon">
                        <i class="bi bi-shield-lock"></i>
                    </div>
                </div>
                <!--                    <div class="form-group position-relative has-icon-left mb-4">-->
                <!--                        <input type="password" class="form-control form-control-xl" placeholder="验证码" id="validateCode">-->
                <!--                        <div class="form-control-icon">-->
                <!--                            <i class="bi bi-shield-lock"></i>-->
                <!--                        </div>-->
                <!--                    </div>-->
                <div class="form-check form-check-lg d-flex align-items-end">
                    <input class="form-check-input me-2" type="checkbox" value="" id="flexCheckDefault">
                    <label class="form-check-label text-gray-600" for="flexCheckDefault">
                        保持登陆
                    </label>
                </div>
                <button class="btn btn-primary btn-block btn-lg shadow-lg mt-5" onclick="login()">登录</button>
                <div class="text-center mt-5 text-lg fs-4">

                </div>
            </div>
        </div>
        <div class="col-lg-7 d-none d-lg-block">
            <div id="auth-right">

            </div>
        </div>
        <div style="width:300px;margin:0 auto; padding:20px 0;text-align: center">
            Copyright &copy; 2023 &mdash; By Mazexal
            <br/>
        </div>
    </div>

</div>

</body>

</html>
<script src="/js/jquery.3.6.0.min.js"></script>
<script>

    function login() {
        var email = $("#email").val();
        var pwd = $("#password").val();
        var validateCode = "validateCode";
        if (validateCode) {
            $.ajax({
                type: 'post',
                url: '/user/login',
                data: JSON.stringify({userName: email, passWord: pwd, validateCode: validateCode}),
                dataType: 'json',
                contentType: 'application/json',
                cache: false
            }).done(function (data) {
                if (data.success) {
                    let userInfo = {};
                    userInfo.userName = email;
                    userInfo.imageHeadUrl = "/image/admin_logo.jpg";
                    userInfo.token = data.data;
                    localStorage.setItem("userInfo", JSON.stringify(userInfo));
                    window.location.href = "/view/home";
                } else {
                    alert(data.errMessage);
                }
            });
        } else {
            alert("验证码不能为空");
        }
    }
</script>